
<template>
  <div class="home-container">
    <grid-layout :layout.sync="layout"
                 :col-num="14"
                 :row-height="35"
                 :is-draggable="false"
                 :is-resizable="false"
                 :is-mirrored="false"
                 :vertical-compact="true"
                 :margin="[20, 20]"
                 :use-css-transforms="true">
      <grid-item class="item"
                 ref="item"
                 v-for="(item,index) in layout"
                 :key="index"
                 :x="Number(item.x)"
                 style="background-color:#fff"
                 :y="Number(item.y)"
                 :w="Number(item.w)"
                 :h="Number(item.h)"
                 :i="item.i">
        <component :key="index"
                   :is="item.i"
                   :height="item.h"
                   :type="item.i"
                   @DynamicNews="getDynamicNews"></component>
      </grid-item>
    </grid-layout>
    <DynamicDialog :dialogVisible.sync="DynamicDialogVisible"
                   :DialogNewForm.sync="DynamicNewForm"></DynamicDialog>
  </div>
</template>
<script>
import { PageComPriviewApi, pageComCustomApi } from "@/services/SystemSetting";
import VueGridLayout from "vue-grid-layout";
import ComponentTotal from "../../pages/layout/ComponentTotal.vue";
import ComponentProjectCount from "../../pages/layout/ComponentProjectCount.vue";
import ComponentDate from "../../pages/layout/ComponentDate";
import ComponentDongTai from "../../pages/layout/ComponentDongTai";
import ComponentgoujianCount from "../../pages/layout/ComponentgoujianCount";
import ComponentPersonCount from "../../pages/layout/ComponentPersonCount";
import ComponentType from "../../pages/layout/ComponentType";
import ComponentYewuCount from "../../pages/layout/ComponentYewuCount";
import unitCountEcharts from "../../pages/layout/unitCountEcharts";
import projectComponentCount from "../../pages/layout/projectComponentCount";
import onKucunCount from "../../pages/layout/onKucunCount";
import processStateCount from "../../pages/layout/processStateCount";
import ComponentTotalNext from "../../pages/layout/ComponentTotalNext";

import car from "../../pages/layout/ComponentDigitalPanel";
import child_company from "../../pages/layout/ComponentDigitalPanel";
import menber from "../../pages/layout/ComponentDigitalPanel";
import project_count from "../../pages/layout/ComponentDigitalPanel";
import component_count from "../../pages/layout/ComponentDigitalPanel";
import projected from "../../pages/layout/ComponentDigitalPanel";
import projecting from "../../pages/layout/ComponentDigitalPanel";
import gps from "../../pages/layout/ComponentDigitalPanel";
import rfid from "../../pages/layout/ComponentDigitalPanel";
import working from "../../pages/layout/ComponentDigitalPanel";
import worked from "../../pages/layout/ComponentDigitalPanel";
import projected_design from "../../pages/layout/ComponentDigitalPanel";
import projecting_design from "../../pages/layout/ComponentDigitalPanel";
import point_count from "../../pages/layout/ComponentDigitalPanel";
import mouth_capacity from "../../pages/layout/ComponentDigitalPanel";
import projected_factory from "../../pages/layout/ComponentDigitalPanel";
import projecting_factory from "../../pages/layout/ComponentDigitalPanel";

//下面是新增的组件(11个)
import AnnualCumulative from "../../pages/layout/newComponent/AnnualCumulative";
import CattleManage from "../../pages/layout/newComponent/CattleManage";
import CumulativeContract from "../../pages/layout/newComponent/CumulativeContract";
import QuantityWork from "../../pages/layout/newComponent/QuantityWork";
import TotalNewSignatures from "../../pages/layout/newComponent/TotalNewSignatures";
import ArchitecturalTypes from "../../pages/layout/newComponent/ArchitecturalTypes";
import CapacityStatistics from "../../pages/layout/newComponent/CapacityStatistics";
import ContractItemDistribution from "../../pages/layout/newComponent/ContractItemDistribution";
import NewlySignedProjects from "../../pages/layout/newComponent/NewlySignedProjects";
import QuantityStatistics from "../../pages/layout/newComponent/QuantityStatistics";
import TotalContractAmount from "../../pages/layout/newComponent/TotalContractAmount";
import DynamicDialog from "../../pages/ConfigCenter/SystemSetting/PageComponent/components/DynamicDialog";
export default {
  components: {
    DynamicDialog,
    GridLayout: VueGridLayout.GridLayout,
    GridItem: VueGridLayout.GridItem,
    car,
    child_company,
    menber,
    project_count,
    component_count,
    projected,
    projecting,
    gps,
    rfid,
    working,
    worked,
    projected_design,
    projecting_design,
    point_count,
    mouth_capacity,
    projected_factory,
    projecting_factory,
    processStateCount,
    onKucunCount,
    projectComponentCount,
    unitCountEcharts,
    ComponentProjectCount,
    ComponentDongTai,
    ComponentDate,
    ComponentgoujianCount,
    ComponentPersonCount,
    ComponentType,
    ComponentYewuCount,
    ComponentTotal,
    ComponentTotalNext,
    AnnualCumulative,
    CattleManage,
    CumulativeContract,
    QuantityWork,
    TotalNewSignatures,
    ArchitecturalTypes,
    CapacityStatistics,
    ContractItemDistribution,
    NewlySignedProjects,
    QuantityStatistics,
    TotalContractAmount
  },
  data () {
    return {
      count: 0,
      layout: [],
      requestParam: {
        page: 1,
        instance_type: this.$route.query.instance_type,
        rela_id: this.$route.query.unitId,
        page_tmp_id: 1
      },
      DynamicDialogVisible: false,
      DynamicNewForm: {},
    };
  },
  computed: {
    getCount () {
      return this.$store.getters.countNum;
    }
  },
  created () { },
  methods: {
    addCount () {
      this.$store.dispatch("addCount", Math.floor(10 * Math.random()));
      console.log(this.$store.state, "addcount");
    },
    getDynamicNews (list, data) {
      var newForm = {};
      this.DynamicDialogVisible = true;
      newForm.title = list.title;
      newForm.name = list.username;
      newForm.classify = data.name;
      newForm.time = list.create_time;
      newForm.content = list.content;
      this.DynamicNewForm = newForm;
    },
    getHomeData () {
      PageComPriviewApi.getIndexLayout({
        params: {
          page_tmp_id: 1,
        }
      }).then(res => {
        if (res.data) {
          this.layout = res.data
        }
      });
    }
  },
  created () {
    this.getHomeData();
  }
};
</script>
<style scoped lang='scss'>
.home-container {
  background: #efeff4;
}
</style>
